/*
Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import Vue from 'vue'
import App from './App'
import router from './router'
import fastclick from 'fastclick'
import VueI18n from 'vue-i18n'
// import Alert from "./components/Alert";
import api from './assets/js/libs/api.js';
import globalData from './assets/js/libs/global.js';
import './assets/css/app.css';
// import './assets/css/bootstrap.min.css';

Vue.config.productionTip = false;
Vue.use(VueI18n);

// Vue.use(Alert);

Vue.prototype.api = api;
Vue.prototype.globalData = globalData;

const i18n = new VueI18n({});
// 移动端点击优化
fastclick.attach(document.body);



/**
 * @description
 * @author (Set the text for this tag by adding docthis.authorName to your settings file.)
 * @date 2019-05-29
 * @param { number } type 1 localStorage 2 sessionStorage
 * @param { string } key 键
 * @param { string } data 要存储的数据
 * @returns
 */
// 如果报prototype无法被识别的错误，可以把原型方法挂在到__proto__
// Vue.prototype.$addStorageEvent = function (type, key, data) {
//     if (type === 1) {
//         // 创建一个StorageEvent事件
//         var newStorageEvent = document.createEvent('StorageEvent');
//         const storage = {
//             setItem: function (k, val) {
//                 localStorage.setItem(k, val);
//                 // 初始化创建的事件
//                 newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);
//                 // 派发对象
//                 window.dispatchEvent(newStorageEvent);
//             }
//         };
//         return storage.setItem(key, data);
//     } else {
//         // 创建一个StorageEvent事件
//         var newStorageEvent = document.createEvent('StorageEvent');
//         const storage = {
//             setItem: function (k, val) {
//                 sessionStorage.setItem(k, val);
//                 // 初始化创建的事件
//                 newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);
//                 // 派发对象
//                 window.dispatchEvent(newStorageEvent);
//             }
//         };
//         return storage.setItem(key, data);
//     }
// };

new Vue({
    router,
    i18n,
    render: function (h) {
        return h(App)
    }
}).$mount('#app');
